import axios from "./index";

//const baseUrl = "http://172.17.2.238:8080";

//新增借款页面中点击 保存
export function saveLoanInfo(info) {
  return axios({
    method: "POST",
    url: "/borrow/saveInfo",
    data: info
  });
}

//新增借款页面中点击 提交审核
export function submitLoanInfo(info) {
  return axios({
    method: "POST",
    url: "/borrow/checkInfo",
    data: info
  });
}

//由新标维护页面点击编辑跳转至新增借款页面中点击 提交审核 或是 保存
export function updateLoanInfo(info) {
  return axios({
    method: "POST",
    url: "/borrow/updateInfo",
    data: info
  });
}


//根据条件分页查询 未审核或是未审核通过的借款
export function getLoanFrom(page, limit, requirement = {}) {
  console.log("requirement: ",requirement);
  return axios({
    method: "POST",
    url: `/borrow/page/condition/${page}/${limit}`,
    data: requirement
  });
}

//在新标维护页面点击编辑使用
export  function getLoanById(id) {
  return axios({
    method: "GET",
    url: `/borrow/getInfo/${id}`
  });
}

export let imageUploadAddress = "/oss/service/file/upload";

//提交审核
export function reviewLoan(info) {
  return axios({
    method: "POST",
    url: "/review/submit",
    data: info
  });
}

//分页条件查询所有状态为 新标待审核 的方法
export function getPendingLoanFrom(page, limit, requirement = {}) {
  return axios({
    method: "POST",
    url: `/review/page/condition/${page}/${limit}`,
    data: requirement
  });
}

//分页条件查询所有状态为待上架的方法
export function getPendingShelfLoanFrom(page, limit, requirement = {}) {
  return axios({
    method: "POST",
    url: `/subject/page/condition/${page}/${limit}`,
    data: requirement
  });
}

//提交标的信息（上架标）
export function shelfLoan(id, info) {
  return axios({
    method: "POST",
    url: `/subject/submit/${id}`,
    data: info
  });
}

//分页条件查询所有状态为 募集中 的标
export function getRecruitingLoan(page, limit, requirement = {}) {
  return axios({
    method: "POST",
    url: `/subject/manage/page/condition/${page}/${limit}`,
    data: requirement
  });
}

//下架标
export function offShelfLoan(id) {
  return axios({
    method: "POST",
    url: `/subject/offShelf/${id}`
  });
}

//查询所有借款标的类别方法
export function getAllLoanType() {
  return axios({
    method: "GET",
    url: "/subject/type/findAll"
  });
}

//分页条件查询所有状态为满标复审的方法
export function getFullBidFrom(page, limit, requirement = {}) {
  return axios({
    method: "POST",
    url: `/subject/review/page/condition/${page}/${limit}`,
    data: requirement
  });
}

//查询满标的信息
export function getFullBid(id) {
  return axios({
    method: "GET",
    url: `/subject/get/review/info/${id}`
  });
}

//提交满标审核信息
export function reviewFullBidLoan(info) {
  return axios({
    method: "POST",
    url: "/subject/review/submit",
    data: info
  });
}

//查询所有借款标
export function getAllLoanFrom(page,limit,requirement){
  return axios({
    method:"POST",
    url:`/subject/findAll/page/condition/${page}/${limit}`,
    data:requirement,
  });
}